//===================================================================
// 项目名 : Hbt.Cur
// 文件名 : IParallelWorkflowEngine.cs
// 创建者 : Claude
// 创建时间: 2024-12-01
// 版本号 : V0.0.1
// 描述    : 并行工作流引擎接口
//===================================================================

using Hbt.Application.Dtos.Workflow;

namespace Hbt.Application.Services.Workflow.Engine.Parallel
{
    /// <summary>
    /// 并行工作流引擎接口
    /// </summary>
    public interface IHbtParallelWorkflowEngine
    {
        /// <summary>
        /// 创建并行分支
        /// </summary>
        /// <param name="instanceId">工作流实例ID</param>
        /// <param name="branchConfig">分支配置</param>
        /// <returns>分支实例列表</returns>
        Task<List<long>> CreateParallelBranchesAsync(long instanceId, HbtParallelBranchConfigDto branchConfig);

        /// <summary>
        /// 检查并行分支完成状态
        /// </summary>
        /// <param name="instanceId">工作流实例ID</param>
        /// <returns>分支完成状态</returns>
        Task<HbtParallelBranchStatusDto> CheckBranchStatusAsync(long instanceId);

        /// <summary>
        /// 等待并行分支汇聚
        /// </summary>
        /// <param name="instanceId">工作流实例ID</param>
        /// <param name="timeout">超时时间</param>
        /// <returns>是否成功汇聚</returns>
        Task<bool> WaitForParallelJoinAsync(long instanceId, TimeSpan timeout);

        /// <summary>
        /// 处理并行分支完成
        /// </summary>
        /// <param name="branchInstanceId">分支实例ID</param>
        /// <returns>是否处理成功</returns>
        Task<bool> HandleBranchCompletionAsync(long branchInstanceId);

        /// <summary>
        /// 获取并行分支信息
        /// </summary>
        /// <param name="instanceId">工作流实例ID</param>
        /// <returns>并行分支信息</returns>
        Task<HbtParallelWorkflowInfoDto> GetParallelWorkflowInfoAsync(long instanceId);

        /// <summary>
        /// 强制汇聚并行分支
        /// </summary>
        /// <param name="instanceId">工作流实例ID</param>
        /// <param name="reason">强制汇聚原因</param>
        /// <returns>是否成功</returns>
        Task<bool> ForceJoinBranchesAsync(long instanceId, string reason);
    }
}
